package com.wss.module.market.ui.goods.detail.adapter;

import com.felipecsl.asymmetricgridview.AsymmetricRecyclerView;
import com.felipecsl.asymmetricgridview.AsymmetricRecyclerViewAdapter;
import com.wss.common.base.adapter.listener.OnListItemClickListener;
import com.wss.common.manage.AbilityToAbility;
import com.wss.module.market.ResourceTable;
import com.wss.module.market.bean.GoodsInfo;
import com.wss.module.market.ui.goods.detail.GoodsDetailAbility;
import com.youth.banner.loader.ImageLoaderInterface;
import ohos.agp.components.Component;
import ohos.agp.components.LayoutScatter;
import ohos.app.Context;
import java.util.ArrayList;

public class RecommendGoodsAdapter implements ImageLoaderInterface<Component> {

    @Override
    public void displayImage(Context context, Object o, Component component) {

    }

    @Override
    public Component createImageView(Context context) {

        Component component = LayoutScatter.getInstance(context)
                .parse(ResourceTable.Layout_market_item_of_goods_recommend,
                        null, false);

        AsymmetricRecyclerView recyclerView = (AsymmetricRecyclerView) component
                .findComponentById(ResourceTable.Id_recycle_view);

        RecommendGoodsInfoAdapter adapter = new RecommendGoodsInfoAdapter(context,
                new ArrayList<>(),
                new OnListItemClickListener<GoodsInfo>() {
                    @Override
                    public void onItemClick(GoodsInfo data, int position) {
                        //推荐位商品详情
                        AbilityToAbility.toAbility(context, GoodsDetailAbility.class);
                    }
                });
        recyclerView.setItemProvider(new AsymmetricRecyclerViewAdapter<>(context, recyclerView, adapter));

        return component;
    }
}
